package net.lanelife.casino.caipiao.dto.admin;

import java.util.List;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Selection;

import net.lanelife.casino.caipiao.entity.PaymentRechargeOrder;
import net.lanelife.casino.caipiao.entity.PaymentRechargeOrder_;
import net.lanelife.casino.common.dto.support.GenericTable;
import net.lanelife.casino.common.entity.json.serialize.CurrencySerializer;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.collect.Lists;

/**
 * @author Lane
 * 
 * 在线支付订单表格
 *
 * @param <DTO>
 */
public class PaymentRechargeOrderTable<DTO> extends GenericTable<DTO, PaymentRechargeOrder> {

	private static final long serialVersionUID = 1526057088045320522L;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double orderAmount;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double factAmount;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double fee;

	public PaymentRechargeOrderTable() {}

	public PaymentRechargeOrderTable(Double orderAmount, Double factAmount,
			Double fee) {
		super();
		this.orderAmount = orderAmount;
		this.factAmount = factAmount;
		this.fee = fee;
	}

	@Override
	public List<Selection<?>> buildExpression(Root<PaymentRechargeOrder> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
		List<Selection<?>> columns = Lists.newArrayList();
		columns.add(builder.sum(root.get(PaymentRechargeOrder_.orderAmount)));
		columns.add(builder.sum(root.get(PaymentRechargeOrder_.factAmount)));
		columns.add(builder.sum(root.get(PaymentRechargeOrder_.fee)));
		return columns;
	}

	public Double getOrderAmount() {
		return orderAmount;
	}

	public void setOrderAmount(Double orderAmount) {
		this.orderAmount = orderAmount;
	}

	public Double getFactAmount() {
		return factAmount;
	}

	public void setFactAmount(Double factAmount) {
		this.factAmount = factAmount;
	}

	public Double getFee() {
		return fee;
	}

	public void setFee(Double fee) {
		this.fee = fee;
	}

}
